package com.forezp;

import com.forezp.data.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;

@SpringBootApplication
@EnableEurekaClient
@RestController
public class ServiceGoApplication {

	public static void main(String[] args) {
		SpringApplication.run(ServiceGoApplication.class, args);
	}

	@Value("${server.port}")
	String port;
	@RequestMapping(value = "/go", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
	public Object home(@RequestBody User user) {
		SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String sdate=format2.format(new Date());
		user.setCreated_at(Timestamp.valueOf(sdate));
		user.setUpdated_at(Timestamp.valueOf(sdate));
		user.setId(2);
		return user;
	}

}
